/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.worldscale.xp.wslib.im.jabber.impl;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;

/**
 *
 * @author Kun
 */
public class MyTCPConnection implements MyAbstractConnection {

    public static MyTCPConnection open(String host, int port) throws IOException {
        final InetSocketAddress addr = new InetSocketAddress(host, port);
        final Socket sock = new Socket();
        sock.connect(addr, 30 * 1000);
        return new MyTCPConnection(sock);
    }
    private final Socket mSocket;

    private MyTCPConnection(Socket sock) throws IOException {
        mSocket = sock;
    }

    public void close() throws IOException {
        mSocket.close();
    }

    public InputStream openInputStream() throws IOException {
        return mSocket.getInputStream();
    }

    public OutputStream openOutputStream() throws IOException {
        return mSocket.getOutputStream();
    }

    public void startTLS() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
